package com.m3839.sdk.ym.widget.toast

import java.lang.ref.WeakReference

/**
 * Description:DigitKeyboard
 *
 * @author 陈宝阳
 * @create 2020/4/11 10: 21
 */
internal class DismissRunnable : WeakReference<YMFloatView?>, Runnable {

    var listener: OnCancelListener? = null

    constructor(toast: YMFloatView?) : super(toast) {}

    constructor(toast: YMFloatView?, listener: OnCancelListener?) : super(
        toast
    ) {
        this.listener = listener
    }

    override fun run() {
        if (listener != null) {
            listener!!.onCancel()
        }
        val view = get()
        if (view != null && view.isShow) {
            view.cancel()
        }
    }
}